package com.ruoyi.user.api;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.user.api.domain.CarUser;
import com.ruoyi.user.api.factory.RemoteCarUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 用户服务
 *
 * @author ruoyi
 */
//contextId的值是为了区分多个相同接口的实现类，防止注入时出现问题
//value的值是服务提供者的名称，也就是在注册中心注册的服务名称
//fallbackFactory的值容器的工厂对象，是容器的托底对象，当服务提供者不可用时，会调用托底对象的方法，返回托底对象的结果
@FeignClient(contextId = "remoteCarUserService", value = ServiceNameConstants.CARUSER_SERVICE, fallbackFactory = RemoteCarUserFallbackFactory.class)
public interface RemoteCarUserService {


    @GetMapping("/user/queryUserByUserName/{username}")
    public CarUser getUserInfoByUserName(@PathVariable("username") String username,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @GetMapping("/user/queryUserById/{id}")
    public CarUser getUserInfoById(@PathVariable("id") Long id,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);

}
